#include<iostream>

using namespace std;


void slove()
{
	int n, k;
	cin >> n >> k;

	string str;
	cin >> str;

	int res = 0;
	int slow = 0;
	int fast = slow + (k - 1);
	int max = 0;
	int maxli = 0;
	int maxri = 0;
	int count = 0;
	int flag = 1;
	int tmp = 0;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == 'B')
		{
			tmp = 1;
		}
	}
	while ( tmp && flag)
	{
		
		while (slow < str.size() && fast < str.size())
		{
			for (int i = slow; i <= fast; i++)
			{
				if (str[i] == 'B')
				{
					count++;
				}
			}

			if (count >= max)
			{
				max = count;
				count = 0;

				maxli = slow;
				maxri = fast;
			}
			else
			{
				count = 0;
			}

			slow++;
			fast++;
		}

		for (int i = maxli; i <= maxri; i++)
		{
			str[i] = 'W';
		}
		res++;
		max = 0;

		for (int i = 0; i < str.size(); i++)
		{
			if (str[i] == 'B')
			{
				flag = 0;
				break;
			}
		}

		if (!flag)
		{
			flag = 1;
		}
		else
		{
			flag = 0;
		}
		slow = 0;
		fast = slow+(k-1);
	}
	cout << res << endl;
}

int main()
{
	int t;
	cin >> t;

	while (t--)
	{
		slove();
	}
	return 0;
}